#! /usr/bin/python
import sys
import os

colSize=2
scanNum=1
cmd = ""
result=""

cmd ="mkdir result"
os.system(cmd)

cmd ="mkdir result/time"
os.system(cmd)

cmd ="mkdir result/event"
os.system(cmd)

cmd ="mkdir result/cpu"
os.system(cmd)

for attrSize in range(1,21):
    cmd= "rm -rf scanTable* whereTable*"
    os.system(cmd)
    cmd = "./scanBinaryGen " +str(colSize) + " 1 1 " + str(attrSize)
    os.system(cmd)
    cmd = "chmod 777 scanTable* whereTable*"
    os.system(cmd)

    result = "result/time/" + str(attrSize) + "_noprof"
    cmd = "./scanTest 1 1 1 "+ str(attrSize) +"  > " + result 
    os.system(cmd)
    os.system(cmd)

    result = "result/time/" + str(attrSize) 
    cmd = "nvprof ./scanTest 1 1 1 "+ str(attrSize) +"  > " + result 
    os.system(cmd)
    os.system(cmd)

    result = "result/cpu/" + str(attrSize) 
    cmd = "./select 1 1 1 "+ str(attrSize) +"  > " + result 
    os.system(cmd)

    result = "result/event/" + str(attrSize) + "_mem_request" 
    cmd = "nvprof --events gld_request,gst_request ./scanTest 1 1 1 "+ str(attrSize) +"  > " + result 
    os.system(cmd)

    result = "result/event/" + str(attrSize) + "_mem_ld_transaction" 
    cmd = "nvprof --events l1_global_load_hit,l1_global_load_miss ./scanTest 1 1 1 "+ str(attrSize) +"  > " + result 
    os.system(cmd)

    result = "result/event/" + str(attrSize) + "_mem_st_transaction" 
    cmd = "nvprof --events global_store_transaction ./scanTest 1 1 1 "+ str(attrSize) +"  > " + result 
    os.system(cmd)

    result = "result/event/" + str(attrSize) + "_inst" 
    cmd = "nvprof --events inst_issued,inst_executed ./scanTest 1 1 1 "+ str(attrSize) +"  > " + result 
    os.system(cmd)

cmd= "rm -rf scanTable* whereTable*"
os.system(cmd)
